from django.db import models

from user.models import SysUser
from rest_framework import serializers


# Create your models here.


class Student(models.Model):
    """ 学生信息表 """
    stu_id = models.CharField(verbose_name='学号', max_length=100, primary_key=True)
    stu_phone = models.CharField(verbose_name='联系方式', max_length=20, null=True, blank=True)
    stu_nation = models.CharField(verbose_name='民族', max_length=10, null=True)
    stu_politic_outlook = models.CharField(verbose_name='政治面貌', max_length=10, null=True)  # 政治面貌
    stu_birth = models.CharField(verbose_name='出生日期', default="", max_length=100)  # 出生日期
    stu_name = models.CharField(verbose_name='姓名', max_length=128)
    stu_enrollment_year = models.CharField(verbose_name='入学年份', default="", max_length=100)  # 级(入学年份)
    stu_type = models.CharField(verbose_name='类型(专/学硕)', max_length=10)  # 学科类型
    stu_img = models.CharField(verbose_name='照片', max_length=255, default="", null=True)
    stu_gender = models.CharField(verbose_name='性别', max_length=5, null=True, blank=True)
    stu_major = models.CharField(verbose_name='专业', default="", max_length=50)  # 专业
    stu_graduate_school = models.CharField(verbose_name='毕业院校', default="", max_length=50)  # 毕业院校
    stu_graduate_major = models.CharField(verbose_name='毕业专业', default="", max_length=50)  # 毕业专业
    stu_fresh_previous = models.CharField(verbose_name='应/历届', default="", max_length=10, null=True)  # 应届/历届
    stu_grade_english = models.CharField(verbose_name='英语成绩', default="", max_length=10, null=True)  #
    stu_grade_math = models.CharField(verbose_name='数学成绩', default="", max_length=10, null=True)  #
    stu_grade_politics = models.CharField(verbose_name='政治成绩', default="", max_length=10, null=True)  #
    stu_grade_procourse = models.CharField(verbose_name='专业课成绩', default="", max_length=10, null=True)  #
    stu_grade_total = models.CharField(verbose_name='总分', default="", max_length=10, null=True)  # 总分
    stu_hobby = models.TextField(verbose_name='爱好', default="", null=True, blank=True)  # 爱好
    stu_honor = models.TextField(verbose_name='获得荣誉', default="", null=True, blank=True)  # 荣誉
    stu_workexperience = models.TextField(verbose_name='工作经历', default="", null=True, blank=True)  # 工作经历
    user_id = models.CharField(verbose_name='关联user表id', default="", max_length=200, null=False,
                               blank=True)  # 关联user表id
    create_time = models.DateField(null=True, verbose_name="创建时间")
    update_time = models.DateField(null=True, verbose_name="更新时间")

    def __str__(self):
        return str(self.stu_name)

    class Meta:
        verbose_name_plural = '学生信息'


class SysStuSerializer(serializers.ModelSerializer):
    class Meta:
        model = Student
        fields = '__all__'


class Teacher(models.Model):
    """ 导师信息表 """
    teacher_id = models.CharField(verbose_name='工号', max_length=20, primary_key=True)  # 工号
    teacher_name = models.CharField(verbose_name='姓名', max_length=128)  # 姓名
    teacher_img = models.CharField(verbose_name='照片', max_length=255, null=True)  # 照片
    teacher_gender = models.CharField(verbose_name='性别', max_length=5, null=True, blank=True)
    teacher_introduction = models.CharField(verbose_name='导师简介', max_length=1200, null=True, blank=True)  # 简介
    teacher_title = models.CharField(verbose_name='职称', max_length=10, null=True, blank=True)  # 职称
    teacher_direction = models.CharField(verbose_name='研究方向', max_length=50, null=True, blank=True)  # 研究方向
    teacher_education = models.CharField(verbose_name='学历', max_length=10, null=True, blank=True)  # 学历
    teacher_birth = models.CharField(verbose_name='出生日期', max_length=10, null=True, blank=True)  # 出生日期
    teacher_phone = models.CharField(verbose_name='联系方式', max_length=20, null=True, blank=True)  # 联系方式
    teacher_dorm = models.CharField(verbose_name='类型(博/硕导)', max_length=5, null=True, blank=True)  # 博导/硕导
    teacher_major = models.CharField(verbose_name='学院', max_length=30, null=True, blank=True)  # 学院
    teacher_course = models.CharField(verbose_name='教授学科', max_length=15, null=True, blank=True)  # 学科
    teacher_field = models.CharField(verbose_name='招生领域', max_length=200, null=True, blank=True)  # 招生领域
    teacher_quota_M = models.IntegerField(verbose_name='专硕名额')  # 专硕名额
    teacher_quota_P = models.IntegerField(verbose_name='学硕名额')  # 学硕名额
    teacher_project = models.TextField(verbose_name='研究项目', blank=True)  # 研究项目
    teacher_honor = models.TextField(verbose_name='获得荣誉', blank=True)  # 荣誉
    user_id = models.CharField(verbose_name='关联user表id', default="", max_length=200, null=False,
                               blank=True)  # 关联user表id
    create_time = models.DateField(null=True, verbose_name="创建时间")
    update_time = models.DateField(null=True, verbose_name="更新时间")

    def __str__(self):
        return str(self.teacher_name)

    class Meta:
        verbose_name_plural = '导师信息'


class SysTeaSerializer(serializers.ModelSerializer):
    class Meta:
        model = Teacher
        fields = '__all__'


class MutualSelection(models.Model):
    """ 互选结果表 """
    teacher_id = models.CharField(verbose_name='导师工号', max_length=9)
    teacher_name = models.CharField(verbose_name='导师姓名', max_length=20)
    stu_id = models.CharField(verbose_name='学生学号', max_length=18)
    stu_name = models.CharField(verbose_name='学生姓名', max_length=20)
    directions = models.CharField(verbose_name='研究方向', max_length=50)  # 研究方向
    type = models.CharField(verbose_name='类型(专/学硕)', max_length=10)  # 专硕/学硕
    add_time = models.DateTimeField(verbose_name='选择日期', auto_now_add=True)  # 日期

    def __str__(self):
        return self.teacher_name + self.stu_name

    class Meta:
        verbose_name_plural = '互选结果'


class MutualSelectionSerializer(serializers.ModelSerializer):
    class Meta:
        model = MutualSelection
        fields = '__all__'
